<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="ArrayList.jsc Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="../index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="../overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="../allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>ArrayList.jsc</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		js.util.ArrayList class http://jsvm.homolo.com/jsvm2.0/docs/api/
 <BR/><BR/><B>Version: </B>2.01, 10/23/05
 <BR/><BR/><B>Author:</B> Wan Changhua
 <BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="ArrayList.html">js.util.ArrayList</a></b></td>
    <td>This is the array class.</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"># language: JSVM2

<span class="comment">/**
 * <span class="attrib">@fileoverview</span> js.util.ArrayList class http://jsvm.homolo.com/jsvm2.0/docs/api/
 * <span class="attrib">@file</span>		ArrayList.jsc
 * <span class="attrib">@author</span>	Wan Changhua
 * <span class="attrib">@version</span>	2.01, 10/23/05
 * <span class="attrib">@since</span>		JSVM1.0
 */</span>

package js.util;

import js.lang.Cloneable;
import js.lang.ArgumentException;


<span class="comment">/**
 * Create a new ArrayList instance.
 * Inherit from Cloneable
 * <span class="attrib">@author</span>	Wan Changhua
 * <span class="attrib">@version</span>	2.01, 10/23/05
 * <span class="attrib">@extends</span> Cloneable
 * <span class="attrib">@class</span> This is the array class.
 * <span class="attrib">@constructor</span>
 */</span>
 
<span class="reserved">function</span> ArrayList ()
{
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 */</span>
	<span class="reserved">this</span>.array = [];
}

<span class="comment">/**
 * Returns an array containing all of the elements in this list
 * in the correct order.
 * <span class="attrib">@return</span> an array containing all of the elements in this list
 * 	       in the correct order.
 * <span class="attrib">@type</span> Array
 */</span>
ArrayList.<span class="reserved">prototype</span>.toArray = <span class="reserved">function</span>()
{
	<span class="reserved">return</span> <span class="reserved">this</span>.array;
}

<span class="comment">/**
 * Searches for the first occurence of the given argument, testing 
 * for equality using the &lt;tt&gt;equals&lt;/tt&gt; method. 
 *
 * <span class="attrib">@param</span>   o   an object.
 * <span class="attrib">@return</span>  the index of the first occurrence of the argument in this
 *          list; returns &lt;tt&gt;-1&lt;/tt&gt; if the object is not found.
 * <span class="attrib">@type</span> int
 */</span>
ArrayList.<span class="reserved">prototype</span>.indexOf = <span class="reserved">function</span>(o)
{
	var l = <span class="reserved">this</span>.array.length;
	<span class="reserved">for</span> (var i = 0; i &lt; l; i++)
	{
		<span class="reserved">if</span> (<span class="reserved">this</span>.array[i] == o)
		{
			<span class="reserved">return</span> i;
		}
	}
	<span class="reserved">return</span> -1;
}

<span class="comment">/**
 * Returns the index of the last occurrence of the specified object in
 * this list.
 *
 * <span class="attrib">@param</span>   o   the desired element.
 * <span class="attrib">@return</span>  the index of the last occurrence of the specified object in
 *          this list; returns -1 if the object is not found.
 * <span class="attrib">@type</span> int
 */</span>
ArrayList.<span class="reserved">prototype</span>.lastIndexOf = <span class="reserved">function</span>(o)
{
	var l = <span class="reserved">this</span>.array.length - 1;
	<span class="reserved">for</span> (var i = l; i &gt;= 0; i--)
	{
		<span class="reserved">if</span> (<span class="reserved">this</span>.array[i] == o)
		{
			<span class="reserved">return</span> i;
		}
	}
	<span class="reserved">return</span> -1;
}

<span class="comment">/**
 * Appends the specified element to the end of this list.
 *
 * <span class="attrib">@param</span> arg1 index at which the specified element is to be inserted.
 * <span class="attrib">@param</span> arg2 element to be appended to this list.
 */</span>
ArrayList.<span class="reserved">prototype</span>.add = <span class="reserved">function</span>(arg1, arg2)
{
	<span class="reserved">if</span> (arguments.length == 1)
	{
		var l = <span class="reserved">this</span>.array.length;
		<span class="reserved">this</span>.array[l] = arg1;
	}
	<span class="reserved">else</span>
	{
		var l1 = <span class="reserved">this</span>.array.length;
		var a1 = <span class="reserved">this</span>.array.slice(0, arg1);
		var a2 = <span class="reserved">this</span>.array.slice(arg1, l1);
		var l2 = a1.length;
		a1[l2] = arg2;
		<span class="reserved">this</span>.array = a1.concat(a2);
	}
}

 <span class="comment">/**
  * Appends all of the elements in the specified Collection to the end of
  * this list, in the order that they are returned by the
  * specified Collection's Iterator.  The behavior of this operation is
  * undefined if the specified Collection is modified while the operation
  * is in progress.  (This implies that the behavior of this call is
  * undefined if the specified Collection is this list, and this
  * list is nonempty.)
  *
  * <span class="attrib">@param</span> c the elements to be inserted into this list.
  * <span class="attrib">@return</span> &lt;tt&gt;true&lt;/tt&gt; if this list changed as a result of the call.
  * <span class="attrib">@throws</span>  ArgumentException if the specified collection is not an Array instance.
  */</span>
ArrayList.<span class="reserved">prototype</span>.addAll = <span class="reserved">function</span>(a)
{
	<span class="reserved">if</span> (a instanceof Array)
	{
		<span class="reserved">this</span>.array = <span class="reserved">this</span>.array.concat(a);
	}
	<span class="reserved">else</span> <span class="reserved">if</span> (typeof(a.toArray) == <span class="literal">"function"</span>
		&amp;&amp; ((a = a.toArray()) instanceof Array))
	{
		<span class="reserved">this</span>.array = <span class="reserved">this</span>.array.concat(a);
	}
	<span class="reserved">else</span>
	{
		throw new ArgumentException(<span class="reserved">this</span>.getClass().getName()
			+ <span class="literal">".addAll(): arguments error."</span>);
	}
}


<span class="comment">/**
 * Removes the element at the specified position in this list.
 * Shifts any subsequent elements to the left (subtracts one from their
 * indices).
 *
 * <span class="attrib">@param</span> i the index of the element to removed.
 * <span class="attrib">@return</span> the element that was removed from the list.
 */</span>
ArrayList.<span class="reserved">prototype</span>.removeAt = <span class="reserved">function</span>(i)
{
	var l = <span class="reserved">this</span>.array.length;
	<span class="reserved">if</span> (i &lt; 0 || i &gt;= l)
	{
		<span class="reserved">return</span> null;
	}
	var o = <span class="reserved">this</span>.Array[i];
	<span class="reserved">this</span>.array = <span class="reserved">this</span>.array.slice(0, i).concat(
		<span class="reserved">this</span>.array.slice(i + 1, l));
	<span class="reserved">return</span> o;
}

<span class="comment">/**
 * Removes the element at the specified position in this list.
 * Shifts any subsequent elements to the left (subtracts one from their
 * indices).
 *
 * <span class="attrib">@param</span> o the element to removed.
 */</span>
ArrayList.<span class="reserved">prototype</span>.remove = <span class="reserved">function</span>(o)
{
	var i = <span class="reserved">this</span>.indexOf(o);
	<span class="reserved">if</span> (i == -1)
	{
		<span class="reserved">return</span> <span class="reserved">this</span>;
	}
	<span class="reserved">return</span> <span class="reserved">this</span>.removeAt(i);
}


 <span class="comment">/**
  * Returns &lt;tt&gt;true&lt;/tt&gt; if this list contains the specified element.
  *
  * <span class="attrib">@param</span> elem element whose presence in this List is to be tested.
  * <span class="attrib">@return</span>  &lt;code&gt;true&lt;/code&gt; if the specified element is present;
  *		&lt;code&gt;false&lt;/code&gt; otherwise.
  * <span class="attrib">@type</span> boolean
  */</span>
ArrayList.<span class="reserved">prototype</span>.contains = <span class="reserved">function</span>(o)
{
	<span class="reserved">return</span> <span class="reserved">this</span>.indexOf(o) != -1;
}


<span class="comment">/**
 * Removes all of the elements from this list.  The list will
 * be empty after this call returns.
 */</span>
ArrayList.<span class="reserved">prototype</span>.clear = <span class="reserved">function</span>()
{
	<span class="reserved">this</span>.array.length = 0;
}


<span class="comment">/**
 * Returns the number of elements in this list.
 *
 * <span class="attrib">@return</span>  the number of elements in this list.
 * <span class="attrib">@type</span> int
 */</span>
ArrayList.<span class="reserved">prototype</span>.size = <span class="reserved">function</span>()
{
	<span class="reserved">return</span> <span class="reserved">this</span>.array.length;
}


<span class="comment">/**
 * Returns the element at the specified position in this list.
 *
 * <span class="attrib">@param</span>  i index of element to return.
 * <span class="attrib">@return</span> the element at the specified position in this list.
 * <span class="attrib">@type</span> Object
 */</span>
ArrayList.<span class="reserved">prototype</span>.get = <span class="reserved">function</span>(i)
{
	var size = <span class="reserved">this</span>.size();
	<span class="reserved">if</span> (i &gt;= 0 &amp;&amp; i &lt; size)
	{
		<span class="reserved">return</span> <span class="reserved">this</span>.array[i];
	}
	<span class="reserved">else</span>
	{
		<span class="reserved">return</span> null;
	}
}


<span class="comment">/**
 * Returns a shallow copy of this &lt;tt&gt;ArrayList&lt;/tt&gt; instance.  (The
 * elements themselves are not copied.)
 *
 * <span class="attrib">@return</span>  a clone of this &lt;tt&gt;ArrayList&lt;/tt&gt; instance.
 * <span class="attrib">@type</span> ArrayList
 */</span>
ArrayList.<span class="reserved">prototype</span>.clone = <span class="reserved">function</span>()
{
	var o = new ArrayList();
	o.addAll(<span class="reserved">this</span>.array);
	<span class="reserved">return</span> o;
}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="../help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="../index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="../overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="../allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Nov 17 20:10:21 2005</div>
</body>
</html>
